package com.ll.studentservice.controller;


import com.ll.commonUtils.R;
import com.ll.studentservice.entity.EduKeInfo;
import com.ll.studentservice.service.EduKeInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程详详细信息表 前端控制器
 * </p>
 *
 * @author ll
 * @since 2020-11-27
 */
@Api(description = "课程详细信息增删改查API") //swagger界面提示
@RestController
@RequestMapping("/studentservice/edukeinfo")
public class EduKeInfoController {

    @Autowired
    private EduKeInfoService eduKeInfoService;

    @GetMapping("findKeInfo/{id}")
    @ApiOperation(value = "获取单个课程信息") //swagger界面提示
    public R findKeInfo(@PathVariable String id){
        EduKeInfo eduKeInfo = eduKeInfoService.getById(id);
        if (StringUtils.isEmpty(eduKeInfo)){
            return R.error().message("获取课程信息失败");
        } else {
            return R.ok().data("keInfo", eduKeInfo);
        }
    }

    @PostMapping("addKeInfo")
    @ApiOperation(value = "添加单个课程信息")
    public R addKeInfo(@RequestBody EduKeInfo eduKeInfo){
        boolean save = eduKeInfoService.save(eduKeInfo);
        return save ? R.ok().message("添加成功") : R.error().message("添加失败");
    }



}

